//if we got something through $_POST  

if (isset($_POST['user'])) {  

conn = mysql_connect('cash2uca.ipagemysql.com', 'cash2uca', 'actW3740!@#$'); 
	if (!$conn) { 
	    die('Could not connect: ' . mysql_error()); 
		} 

mysql_select_db(cash2uca);

     include('db.php');  

     $db = new db();  

     // never trust what user wrote! We must ALWAYS sanitize user input  

     $username = mysql_real_escape_string($_POST['user']);  

     // build your query to the database  

     $sql = "SELECT count(*) as num FROM AdminTables WHERE username = " . $username;  

     // get results  

     $row = $db->select_single($sql);  

     if($row['num'] == 0) {  

         echo 'Username <em>'.$username.'</em> is available!';  

     } else {  

         echo 'Username <em>'.$username.'</em> is already taken!';  

     }  

 } 
